package com.ys.otms.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ys.otms.dto.ParamDto;
import com.ys.otms.services.IBillsServices;
import com.ys.otms.utils.DateUtil;
import com.ys.otms.utils.PageUtil;
import com.ys.otms.utils.StringUtil;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/9/17.
 */
@Controller
@RequestMapping("/bills")
public class BillsController {
    private static Logger logger = LoggerFactory.getLogger(BillsController.class);

    @Autowired
    private IBillsServices iBillsServices;

    /**
     * 查询充值记录
     * @param
     * @return
     * @throws Exception
     */
    @RequestMapping("/selectBillsQuery")
    @ResponseBody
    public String selectBillsQuery(@RequestParam(value = "page")String page,@RequestParam(value = "limit")String limit,HttpServletRequest request) throws Exception{
        logger.info("BillsController selectBillsQuery start");
        Map<String,Object> map = new HashMap<>();
        try {
            ParamDto paramDto = new ParamDto();
            PageUtil.setPage(Integer.parseInt(page),Integer.parseInt(limit),paramDto);
            map = iBillsServices.selectBillsQuery(request,paramDto);
            map.put("code","");
            map.put("msg","");
        } catch (Exception e) {
            logger.error("BillsController selectBillsQuery Exception",e);
            map.put("msg","查询失败");
            map.put("code","");
        }
        return new ObjectMapper().writeValueAsString(map);
    }

}
